package com.miya.lib_common.ui_contract;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;

import com.miya.lib_common.ui_contract.contract.BaseContract;
import com.miya.lib_common.ui_contract.contract.XContract;

/**
 * @author robin 2023-06-10 created
 */
public abstract class XFragment<Contract extends BaseContract<XContract.BaseView>, VB extends ViewBinding> extends Fragment implements XContract.BaseView {
    protected Contract presenter;

    abstract Contract bindContract();

    protected VB binding;

    abstract VB bindViewBinding(LayoutInflater inflate);


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        presenter = bindContract();
        binding = bindViewBinding(inflater);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        onCreated();
    }

    public abstract void onCreated();

    @Override
    public void start() {

    }
}
